function Order(jsonObject) {
	this.internalObject = jsonObject;
}

Order.prototype = {
	getCustomerId: function() { return this.internalObject.CustomerId; },
	setCustomerId: function(customerid) { this.internalObject.CustomerId = customerid; },
	getEmployeeId: function() { return this.internalObject.EmployeeId; },
	setEmployeeId: function(employeeid) { this.internalObject.EmployeeId = employeeid; },
	getFreight: function() { return this.internalObject.Freight; },
	setFreight: function(freight) { this.internalObject.Freight = freight; },
	getOrderDate: function() { return this.internalObject.OrderDate; },
	setOrderDate: function(orderdate) { this.internalObject.OrderDate = orderdate; },
	getOrderId: function() { return this.internalObject.OrderId; },
	getRequiredDate: function() { return this.internalObject.RequiredDate; },
	setRequiredDate: function(requireddate) { this.internalObject.RequiredDate = requireddate; },
	getShipAddress: function() { return this.internalObject.ShipAddress; },
	setShipAddress: function(shipaddress) { this.internalObject.ShipAddress = shipaddress; },
	getShipCity: function() { return this.internalObject.ShipCity; },
	setShipCity: function(shipcity) { this.internalObject.ShipCity = shipcity; },
	getShipCountry: function() { return this.internalObject.ShipCountry; },
	setShipCountry: function(shipcountry) { this.internalObject.ShipCountry = shipcountry; },
	getShipName: function() { return this.internalObject.ShipName; },
	setShipName: function(shipname) { this.internalObject.ShipName = shipname; },
	getShippedDate: function() { return this.internalObject.ShippedDate; },
	setShippedDate: function(shippeddate) { this.internalObject.ShippedDate = shippeddate; },
	getShipPostalCode: function() { return this.internalObject.ShipPostalCode; },
	setShipPostalCode: function(shippostalcode) { this.internalObject.ShipPostalCode = shippostalcode; },
	getShipRegion: function() { return this.internalObject.ShipRegion; },
	setShipRegion: function(shipregion) { this.internalObject.ShipRegion = shipregion; },
	getShipVia: function() { return this.internalObject.ShipVia; },
	setShipVia: function(shipvia) { this.internalObject.ShipVia = shipvia; },
	getCreatedDate: function() { return this.internalObject.CreatedDate; },
	getCreatedBy: function() { return this.internalObject.CreatedBy; },
	getModifiedDate: function() { return this.internalObject.ModifiedDate; },
	getModifiedBy: function() { return this.internalObject.ModifiedBy; },
	getOrderObject: function() { return this.internalObject; }
};

function OrderService() {
}

OrderService.prototype.retrieveAll = function(successCallback) {
    viewServiceProxy.invokeGet("OrderList", successCallback, OnPageError, true);
};

OrderService.prototype.retrievePaged = function(successCallback, pageIndex, pageSize, sortOrder, sortColumn, linq) {
    var restUrl = "OrderListPage";
    restUrl = restUrl + "/?";

    if (!IsNullOrEmpty(pageIndex)) {
        restUrl = restUrl + "pageIndex=" + pageIndex;
        if (!IsNullOrEmpty(pageSize) || !IsNullOrEmpty(sortOrder) || !IsNullOrEmpty(sortColumn) || !IsNullOrEmpty(linq)) {
            restUrl = restUrl + "&";
        }
    }
    if (!IsNullOrEmpty(pageSize)) {
        restUrl = restUrl + "pageSize=" + pageSize;
        if (!IsNullOrEmpty(sortOrder) || !IsNullOrEmpty(sortColumn) || !IsNullOrEmpty(linq)) {
            restUrl = restUrl + "&";
        }
    }
    if (!IsNullOrEmpty(sortOrder)) {
        restUrl = restUrl + "sortOrder=" + sortOrder;
        if (!IsNullOrEmpty(sortColumn) || !IsNullOrEmpty(linq)) {
            restUrl = restUrl + "&";
        }
    }
    if (!IsNullOrEmpty(sortColumn)) {
        restUrl = restUrl + "sortColumn=" + sortColumn;
        if (!IsNullOrEmpty(linq)) {
            restUrl = restUrl + "&";
        }
    }
    restUrl = restUrl + "linq=" + linq;

    viewServiceProxy.invokeGet(restUrl, successCallback, OnPageError, true);
};

OrderService.prototype.save = function(order, successCallback) {
viewServiceProxy.invokePut("Order", order.getOrderObject(), successCallback, OnPageError, true);
};
